<template>
	<view>
		<TopHead :title="'我的二维码'"></TopHead>
		<view class="conbox">

			<image class="erCodeImg" :src="imgPath"></image>

		</view>

	</view>
</template>

<script>
	import TopHead from '../../components/topHead/topHead.vue';
	export default {
		components: {
			TopHead
		},
		data() {
			return {
				certificateId: '',
				newuser: '', // 
				userDataInfo: {}, // 
				page: 1,
				pageSize: 10,
				list: [],
				total: 0, //
				storeId:'',
				sellerId:'',
				imgPath: ""
			}
		},
		onLoad(options) {
			if (options.storeId) {
				this.storeId = options.storeId
				this.sellerId = options.sellerId
			}
			this.$nextTick(()=>{
				this.getData()
			})
		},
		onShow() {
			var userInfo=JSON.parse(uni.getStorageSync('user_info')) ;
			this.sellerId=userInfo.id;
			this.storeId=userInfo.storeId;
		},
		onReachBottom() {
			// 触底分页
			console.log('触底')
			// if (this.total > this.list.length) {
			// 	this.page = parseInt(this.page) + 1
			// }
		},
		methods: {

			// 充值记录
			getData() {
				let _this = this;
				let data = {

				}
				let storeId = this.storeId
				let sellerId = this.sellerId
				_this.$http.fetchData({
					url: `/wechatApplet/worker/user/shareCode?storeId=${storeId}&sellerId=${sellerId}`,
					method: 'GET',
					data: {},
					success(res) {
						// uni.showToast({
						// 	title: res.message,
						// 	icon: 'none'
						// });
						if (res.code != 200) {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
							return;
						}

						var data = res.data;
						// console.log(data);
						_this.imgPath = data;
						// console.log("this.imgPath", _this.imgPath);

					}
				})
			},
			// 绑定卡券
			handData() {
				let _this = this;
				let userId = uni.getStorageSync('id')
				let data = {
					certificateId: _this.certificateId,
					userId: userId
				}
				console.log(data)
				_this.$http.fetchData({
					url: '/wechatApplet/customer/certificate/' + _this.certificateId + '/' + userId,
					method: 'POSt',
					data: {},
					success(res) {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});

						_this.close()
						_this.certificateId = '' // 清空输入框
					}
				})
			},
			// dianhua
			phoneCall(item) {
				uni.makePhoneCall({
					phoneNumber: '023-62433333' //仅为示例
				});
			},
			open() {
				this.$refs.popup.open('center')
			},
			close() {
				this.$refs.popup.close()
			}


		}
	}
</script>

<style scoped>
	.conbox {
		padding: 30rpx;
		padding-top: 196rpx;
	}
	
	.conbox .erCodeImg {
		width: 586rpx;
		height: 632rpx;
		border-radius: 10rpx;
		display: block;
		margin: 0 auto;
		margin-top: 80rpx;
	}
</style>